layui.use(['form','layer','upload','layedit'],function(){
	   var form = layui.form
       layer = parent.layer === undefined ? layui.layer : top.layer,
       $ = layui.jquery,
       laydate = layui.laydate,
       laytpl = layui.laytpl,
       upload = layui.upload;
	   var layedit = layui.layedit;
  
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test1'
	            ,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	            ,method: 'POST'
	            ,done: function(res){
	                //上传完毕
	                if(res.code == 1){
	                	$('#demo1').attr('src', res.data);
	                	var imgId = $("#imgId1").val();
	                	var url = res.data;
	                	var data = {
	        	    			id: imgId,
	        	    			url: url,
	        	    			type:2,
	        	    			orderby : 1
	        	    	}
	                   	$.ajax({
	                   		url: Feng.ctxPath+"/modular/images/update",
	        	    		data: JSON.stringify(data),
	        	    		type: "post",
	        	    		contentType: "application/json;charset=UTF-8",
	        	    		async: false,//关闭异步请求
	        	    		dataType: "json",
	        	    		success: function (data) {
	        	    			if (data.code == 200) {
	        	    				Feng.success('上传成功')
	        	    			} else {
	        	    				Feng.error("操作失败");
	        	    			}
	        	    		}
	        	    	});
	                }
	             }
	    });
	    
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test2'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo2').attr('src', res.data);
	    						var imgId = $("#imgId2").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 2
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test3'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo3').attr('src', res.data);
	    						var imgId = $("#imgId3").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 3
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test4'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo4').attr('src', res.data);
	    						var imgId = $("#imgId4").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 4
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test5'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo5').attr('src', res.data);
	    						var imgId = $("#imgId5").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 5
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test6'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo6').attr('src', res.data);
	    						var imgId = $("#imgId6").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 6
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test7'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo7').attr('src', res.data);
	    						var imgId = $("#imgId7").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 7
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test8'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo8').attr('src', res.data);
	    						var imgId = $("#imgId8").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 8
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test9'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo9').attr('src', res.data);
	    						var imgId = $("#imgId9").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 9
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test10'
	    		,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	    			,method: 'POST'
	    				,done: function(res){
	    					//上传完毕
	    					if(res.code == 1){
	    						$('#demo10').attr('src', res.data);
	    						var imgId = $("#imgId10").val();
	    						var url = res.data;
	    						var data = {
	    								id: imgId,
	    								url: url,
	    								type:2,
	    								orderby : 10
	    						}
	    						$.ajax({
	    							url: Feng.ctxPath+"/modular/images/update",
	    							data: JSON.stringify(data),
	    							type: "post",
	    							contentType: "application/json;charset=UTF-8",
	    							async: false,//关闭异步请求
	    							dataType: "json",
	    							success: function (data) {
	    								if (data.code == 200) {
	    									Feng.success('上传成功')
	    								} else {
	    									Feng.error("操作失败");
	    								}
	    							}
	    						});
	    					}
	    				}
	    });
	    
	    $(document).on('click', '#btnOpen', function(data) {
	    	var imgId = $(this).attr("data-id");
	    	var type = $(this).attr("name");
	    	var data = {
					id: imgId,
					upurl: type,
			}
	    	$.ajax({
				url: Feng.ctxPath+"/modular/images/update",
				data: JSON.stringify(data),
				type: "post",
				contentType: "application/json;charset=UTF-8",
				async: false,//关闭异步请求
				dataType: "json",
				success: function (data) {
					if (data.code == 200) {
						Feng.success('操作成功')
						window.location.reload();
					} else {
						Feng.error("操作失败");
					}
				}
			});
	    });
	    
});